package upmc.fr.android.rss;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class RSSCategory implements Serializable 
{
	private static final long serialVersionUID = 1L;
	private String name;
	private List<RSSFlow> flows = new LinkedList<RSSFlow>();
	
	public RSSCategory(String name)
	{
		this.name = name;		
	}
	
	public String getName() 
	{
		return name;
	}
	
	public List<RSSFlow> getFlows() 
	{
		return flows;
	} 
	
	public void addFlow(RSSFlow flow)
	{
		this.flows.add(flow);
	}
	
	public void removeFlow(RSSFlow flow)
	{
		this.flows.remove(flow);
	}

	@Override
	public int hashCode() 
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((flows == null) ? 0 : flows.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) 
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof RSSCategory))
			return false;
		RSSCategory other = (RSSCategory) obj;
		if (flows == null) 
		{
			if (other.flows != null)
				return false;
		} 
		else if (!flows.equals(other.flows))
			return false;
		if (name == null) 
		{
			if (other.name != null)
				return false;
		} 
		else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	
}
